package com.jp.annotation;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Main {
    public static void main(String[] args) {
        System.out.println("Annotation");
        // 判断@Report是否存在于Person类:
        if (Person.class.isAnnotationPresent(Report.class)) {
            System.out.println("Person.class 存在注解");
        }


        for (Field field : Person.class.getDeclaredFields()) {
            if (field.isAnnotationPresent(Report.class)) {
                System.out.println("Field " + field.getName() + " 存在注解");
            }
        }

        for (Method method : Person.class.getDeclaredMethods()) {
            if (method.isAnnotationPresent(Report.class)) {
                System.out.println("Method " + method.getName() + " 存在注解");
            }
        }


        for (Constructor<?> constructor : Person.class.getDeclaredConstructors()) {
            if (constructor.isAnnotationPresent(Report.class)) {
                System.out.println("Constructor " + constructor.getName() + " 存在注解");
            }
        }
    }
}
